#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <unistd.h>
#include <math.h>

#define N 5000
#define M 1000
#define GRID_SIZE       100
#define MEAN            50
#define STD_DEV         10
#define Pi 3.141592653589793238462643
/*
double normal(void){
        double ret = 0;
        static int valid = 0;
        double mean = MEAN, stddev = STD_DEV;
        double theta = 2 * Pi* (double)rand()/RAND_MAX;
        double rho = sqrt(-2 * log(1 - (double)rand()/RAND_MAX));
        double scale = stddev * rho;
        double x = mean + scale * cos(theta);
        double y = mean + scale * sin(theta);
        if(valid == 0){
                valid =1;
                ret = abs(x);
        }else{
                valid = 0;
                ret = abs(y);
        }

        if(ret > GRID_SIZE - 1 || ret < -0.0000000001)
                return normal();
        else
                return ret;
}
*/


int main(void){
	int fact, dim ;
	int i,j;
	int key,value;
	dim = open("./dimTable",O_RDWR|O_CREAT);
	for(i=0;i<N*M*16;i++){
		write(dim,&i,sizeof(int));
		srandom(i*i+1);
		value = random();
		write(dim,&value,sizeof(int));
	}
	close(dim);
	return 0;
	fact = open("./factTable",O_WRONLY|O_CREAT);
	srandom(0);
	for(j=0;j<25;j++){
		for(i=0;i<N*M;i++){
			srandom(i+i*j+1);
			key = random() % (N*M);
			value = random();
			write(fact,&key,sizeof(int));
			write(fact,&value,sizeof(int));
		}
	}
	close(fact);
	return 0;
}
